﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;

namespace PDX.Validation
{
    /// <summary>
    /// Attaches a <see cref="ValidationManager"/> to a <see cref="Context"/>.
    /// </summary>
    public class ValidationManagerAttacher : IAttacher<Context>
    {
        /// <summary>
        /// Attaches a <see cref="ValidationManager"/> to a <see cref="Context"/>.
        /// </summary>
        /// <param name="context">The context.</param>
        public void Attach(Context context)
        {
            var adapters = Services.Singletons.ServiceProvider.ResolveAll<IValidationAdapter>();
            var adapter = new CompositeValidationAdapter(adapters);

            var notifierFactory = Services.Singletons.ServiceProvider.Resolve<Notification.INotificationManagerFactory>();
            var notifier = notifierFactory.Create(context);

            var vm = new ValidationManager(context, adapter, notifier);
        }
    }
}
